<template>
	<BaseContainer>
		<el-tabs v-model="activeName" class="demo-tabs" @tab-click="onTabClick" tabPosition="left">
			<el-tab-pane v-for="(item, index) in tabs" :key="index" :label="item.label" :name="item.name">
				<component v-if="activeName == item.name" :is="item.component" :creditCode="item.creditCode"
				:isWithAuth="0" :ifShowSearch="false"></component>
			</el-tab-pane>
		</el-tabs>
	</BaseContainer>
</template>

<script setup lang="ts">
import InstitutionOperationSubsidies from '@/views/datacenter/business/subsidyFunds/InstitutionOperationSubsidies/index.vue'
import MedicalInstitutionalSubsidies from '@/views/datacenter/business/subsidyFunds/MedicalInstitutionalSubsidies/index.vue'
import OldUniversitySubsidies from '@/views/datacenter/business/subsidyFunds/OldUniversitySubsidies/index.vue'
import FiveCategoriesOldSubsidies from '@/views/datacenter/business/subsidyFunds/FiveCategoriesOldSubsidies/index.vue'
import LevelUpSubsidies from '@/views/datacenter/business/subsidyFunds/LevelUpSubsidies/index.vue'
import BedConstructionSubsidies from '@/views/datacenter/business/subsidyFunds/BedConstructionSubsidies/index.vue'
import HomeBedSubsidy from '@/views/datacenter/business/subsidyFunds/HomeBedSubsidy/index.vue'
import { useCommonStore } from '@/stores/common'
let { setMoreSearch } = useCommonStore()
type Props = {
	nowRowData?: any
}
const props = withDefaults(defineProps<Props>(), {
	nowRowData: {},
})
setMoreSearch({
	params: {
		creditCode: props.nowRowData.creditCode,
	},
})
let rowData: any = inject('nowRowData')
console.log('接收到', rowData)
let creditCode = props.nowRowData.creditCode || ''
const crud = ref()
const tabs = [
	{ label: '机构运营补贴', name: '1', component: InstitutionOperationSubsidies, creditCode },
	{ label: '机构床位建设补贴', name: '2', component: BedConstructionSubsidies, creditCode },
	{ label: '医疗机构补贴', name: '3', component: MedicalInstitutionalSubsidies, creditCode },

	{ label: '老年大学补贴', name: '4', component: OldUniversitySubsidies, creditCode },
	{ label: '等级提升补贴', name: '5', component: LevelUpSubsidies, creditCode },
	{ label: '“五类老人”入住机构补贴', name: '6', component: FiveCategoriesOldSubsidies, creditCode },
	{ label: '家庭养老床位运营补贴', name: '7', component: HomeBedSubsidy, creditCode },
]

let activeName = ref(tabs[0].name)

const onTabClick = (tab) => {
	activeName = tab.props.name
	setMoreSearch({
		params: {
			creditCode: props.nowRowData.creditCode,
		},
	})
	nextTick(() => {
		crud.value?.refreshChange({ dataType: tab.props.name })
	})
}
onUnmounted(() => {
	setMoreSearch({})
})
</script>

<style scoped></style>
